{extend name="base"/}
{block name="title"}
<title>{$config.seo_title}</title>
<meta name="keywords" content="{$config.seo_keywords}" />
<meta name="description" content="{$config.seo_description}" />
{/block}
{block name="name"}充值{/block}
{block name="base"}{/block}
{block name="content"}

<div class="pay">
    <div class="top">
        <div class="name">
            用户名 <br>
            {$user.username}
        </div>
        <div class="money">
            <div class="left">
                <p>{$user.recharge_money}</p>
                <p>本金（元）</p>
            </div>
            <div class="right">
                <p>{$user.profit}</p>
                <p>盈利（元）</p>
            </div>
        </div>
    </div>
    <div class="method">
        <input type="text" placeholder="输入充值金额" name="money">
        <div class="building">
            <span>支付宝账号:</span>
            <span>{$user.alipay}<input type="hidden" name="alipay" value="{$user.alipay}"></span>
        </div>
        <input type="text" placeholder="输入支付宝订单编号" name="alipay_sn">
        <button onclick="formSubmit()">提交</button>
        <p>支付方式一：扫码支付</p>
        <img class="er" src="{$config.qr}" alt="">
        <p>支付方式二：支付宝账户转账</p>
        <p>转账账号：{$config.account}</p>
    </div>
</div>

{/block}

{block name="js"}
<script type="text/javascript" src="__ORG__/layer/layer.js"></script>
<script>
    function formSubmit() {
        var money = $("input[name='money']").val();
        var alipay_sn = $("input[name='alipay_sn']").val();
        var alipay = $("input[name='alipay']").val();
        if (money == '' || money == undefined) {
            layer.msg('请输入充值金额');
            return false;
        }
        if (alipay_sn == '' || alipay_sn == undefined) {
            layer.msg('请支付宝订单编号');
            return false;
        }
        $.post("{:url('/recharge')}", {money:money,alipay_sn:alipay_sn,alipay:alipay}, function (data) {
            layer.msg(data.msg,{time: 6000});
            if (data.code) {
                setTimeout(function () {
                    location.href = '{:url("/user")}';
                },5000);
            }
        });
    }
</script>

{/block}